cmake_minimum_required(VERSION 3.5)
project(qtwin LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

#add_definitions(-DUSE_GLEW)
add_definitions(-DPRO_ROOT="${CMAKE_CURRENT_SOURCE_DIR}")

set(USE_GLEW OFF)

#if(USE_GLEW)
#	set(glew_DIR $ENV{glew_DIR})
#endif()

set(spdlog_DIR $ENV{spdlog_DIR})
set(Qt5Gui_DIR $ENV{Qt5_HOME}/lib/cmake/Qt5Gui)
set(Qt5Core_DIR $ENV{Qt5_HOME}/lib/cmake/Qt5Core)
set(Qt5OpenGL_DIR $ENV{Qt5_HOME}/lib/cmake/Qt5OpenGL)
set(Qt5Widgets_DIR $ENV{Qt5_HOME}/lib/cmake/Qt5Widgets)

find_package(spdlog)
find_package(Qt5Gui)
find_package(Qt5Core)
find_package(Qt5OpenGL)
find_package(Qt5Widgets)

message(STATUS "glew_DIR is ${glew_DIR}")
if (WIN32)
	message(STATUS "the system is win")
elseif (APPLE)
	message(STATUS "the system is apple")
elseif (UNIX)
	message(STATUS "the system is unix")
endif ()

include_directories(
  include
  spdlog
  ${Qt5Gui_INCLUDE_DIRS}
  ${Qt5Widgets_INCLUDE_DIRS}
  #if(USE_GLEW)
  #${glew_DIR}/include
  #endif()
)

#link_directories(
#  $ENV{Qt5_HOME}/bin
#)

file(GLOB PRO_QRCS "*.qrc")
file(GLOB PRO_SRCS "src/*.cpp")
file(GLOB PRO_INCS "include/*.hpp")

add_executable(${PROJECT_NAME}
  ${PRO_SRCS}
  ${PRO_INCS}
  ${PRO_QRCS}
)

target_link_libraries(${PROJECT_NAME} 
  Qt5::Core
  Qt5::Gui
  Qt5::Widgets 
  Qt5::OpenGL
  spdlog::spdlog
  #if(USE_GLEW)
	#${glew_DIR}/lib/Release/x64/glew32.lib
  #endif()
)

